package com.bjgraphite.report.config;

import com.bjgraphite.report.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
  
@Configuration  
public class WebConfig implements WebMvcConfigurer {



    @Autowired
    private LoginInterceptor loginInterceptor;
  
    /*@Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**") // 允许所有路径的跨域请求
                .allowedOrigins("*") // 允许的源
                .allowedMethods("GET", "POST", "PUT", "DELETE") // 允许的请求方法
                .allowedHeaders("*") // 允许的请求头
                .allowCredentials(false); // 是否允许携带凭证
    }*/


    /**
     *  拦截器
     * @param registry
     * @return
     * @author zhouxiaolong
     * @date 2022/5/13 15:00
     **/
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor).addPathPatterns("/admin/**");
    }
}